package com.hx.net.c;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @author jxlgcmh
 * @create 2019-05-10 21:36
 */
public class UDPClient {
    public static void main(String[] args) throws Exception {

        DatagramSocket socket = new DatagramSocket();
        String str = "我是UDP方式发送的导弹";
        byte[] data = str.getBytes();
        InetAddress inet = InetAddress.getLocalHost();
        DatagramPacket packet = new DatagramPacket(data, 0, data.length, inet, 8888);

        socket.send(packet);

        socket.close();


    }
}
